R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

Install packages and load the libraries and data

# install.packages("TSstudio")

library(TSstudio)
## Warning: package 'TSstudio' was built under R version 3.6.3
data(USgas)

Plotting time series data

Seasonality analysis

Correlation analysis

Training forecasting models

## Warning: package 'forecast' was built under R version 3.6.3
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
## # A tibble: 6 x 7
##   model_id model  notes      avg_mape avg_rmse `avg_coverage_8~ `avg_coverage_9~
##   <chr>    <chr>  <chr>         <dbl>    <dbl>            <dbl>            <dbl>
## 1 hw       HoltW~ HoltWinte~   0.0482     144.            0.792            0.931
## 2 ets1     ets    ETS model~   0.0526     156.            0.833            0.972
## 3 arima2   arima  SARIMA(2,~   0.0546     163.            0.583            0.819
## 4 ets2     ets    ETS model~   0.0650     185.            0.5              0.792
## 5 tslm     tslm   tslm mode~   0.0854     242.            0.319            0.611
## 6 arima1   arima  ARIMA(2,1~   0.163      539.            0.861            0.958
## Warning in ts_grid(USgas, model = "HoltWinters", periods = 6, window_space =
## 6, : The value of the 'alpha' parameter cannot be equal to 0 replacing 0 with
## 1e-5
## Warning in ts_grid(USgas, model = "HoltWinters", periods = 6, window_space =
## 6, : The value of the 'beta' parameter cannot be equal to 0 replacing 0 with
## 1e-5
## Warning in ts_grid(USgas, model = "HoltWinters", periods = 6, window_space =
## 6, : The value of the 'gamma' parameter cannot be equal to 0 replacing 0 with
## 1e-5
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo 
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo 
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo 
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo 
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo 
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo